feat(direnv): nix-direnv で devShell を自動有効化する#155
Closed
nkoji21 wants to merge 1 commit into
Closed
Conversation
Nix flake の devShell をディレクトリ移動で自動有効化するため direnv を 導入する。direnv 本体は aqua で管理(1ツール1ファイル規約に従い imports/direnv.yaml に切り出し、checksum も記録)。nix-direnv は checksum 固定の source_url で direnvrc から読み込み、評価結果をキャッシュ して2回目以降を高速化する。nix-direnv は bash 4.4+ を要求するため Brewfile に bash を追加(macOS 同梱は 3.2)。zsh フックは .zshrc の プラグイン節に追加し、install.sh に direnvrc の symlink を足す。
Owner
Author
|
CPP-Module の devShell 自動有効化が目的だが、その1用途のために dotfiles 全体へ aqua / Brewfile(bash) / 手書き direnvrc の3レイヤーを入れるのは過剰。かつ nix-direnv を使うのに Nix の管理機構を使わないねじれ構成になっている。direnv が必要なら home-manager の programs.direnv で一括管理する形(dotfiles の Nix 化込み)を別途検討する。それまでクローズ。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CPP-Module で導入する Nix flake の devShell を、ディレクトリに入った
だけで自動有効化したい。そのための direnv + nix-direnv を整える。
これまで手元に direnv が無く、入れても hook も無い状態だったため、
宣言的に再現できる形でまとめる。
Changes
aqua/imports/direnv.yamlに切り出し、aqua-checksums.jsonにchecksum を記録(
require_checksum: true準拠)。direnv/direnvrc: nix-direnv を checksum 固定の source_url で読み込む。global に置くことで各リポジトリの
.envrcはuse flakeの1行で済む。Brewfile: bash を追加。nix-direnv は bash 4.4+ を要求するがmacOS 同梱は 3.2 のため(brew の 5.x を PATH 前方で優先させる)。
.zshrc: プラグイン節にeval "$(direnv hook zsh)"を追加。install.sh:~/.config/direnv/direnvrcの symlink 作成を追加。Notes
c++が Nix の clang 19.1.7(システムの Apple clang ではない)を指し、
make/lefthookも devShell 由来になる。nix-direnv のキャッシュ(Renewed cache)も確認。